package com.example.yt_app.Fragment.LoginFragment;

import android.annotation.SuppressLint;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.Toast;

import com.example.yt_app.Fragment.BaseFragment.BaseFragment;
import com.example.yt_app.Fragment.BaseFragment.BaseImmersionFragment;
import com.example.yt_app.R;
import com.example.yt_app.Urils.State;
import com.gyf.immersionbar.ImmersionBar;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by dell on 2021/7/15.
 */

@SuppressWarnings("ALL")
public class PhoneFragment extends BaseFragment {
    @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
    @SuppressLint("NonConstantResourceId")
    @BindView(R.id.login_bt)
    Button login_bt;
    @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
    @BindView(R.id.Buttonc_ok_1)
    CheckBox Buttonc_ok_1;
    private long downTime = 0;
    //Button被按下时的时间
    private long thisTime = 0;
    @Override
    protected void setListener() {
        //给CheckBox设置事件监听
        Buttonc_ok_1.setOnCheckedChangeListener((buttonView, isChecked) -> {
            // TODO Auto-generated method stub
            State.READ_2 = isChecked;
        });
        Login_btn();
    }
    @Override
    protected int getLayoutId() {
        return R.layout.fragment_phone_login;
    }
    /**
     * 点击事件
     * */
    @SuppressWarnings("AlibabaSwitchStatement")
    @OnClick({R.id.send_yanzhengma})
    public void onClick(View v) {
        //noinspection AlibabaSwitchStatement
        switch (v.getId()){

            /**
             *  验证发送
             * */
            case R.id.send_yanzhengma:
                /*密码*/
                if(State.READ_2== true){
                    showMessage("发送成功");
                }else{
                    showMessage("请勾选阅读条例");
                }
                break;

        }
    }
    /**
     * 设置登录的点击事件
     * */
    @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
    public void Login_btn(){
        login_bt.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                downTime = event.getDownTime(); //手指按下时间
                thisTime = event.getEventTime();
                switch (event.getAction()) {

                    case MotionEvent.ACTION_UP: //手指抬起
                        if (thisTime - downTime > State.MIN_CLICK_DELAY_TIME ){
                            /*密码*/
                            if(State.READ_2== true){
                                showMessage("发送成功");
                            }else{
                                showMessage("请勾选阅读条例");
                            }
                        }
                        //短按事件
                        break;
                    default:break;
                }
                return false;
            }
        });
    }
    /**
     * 功能：消息通知栏
     * 作用：通知用户现在的进程
     *
     * */
    @SuppressWarnings("AlibabaRemoveCommentedCode")
    @Override
    public void showMessage(String message) {
        /*
         * 线程里面需要使用到
         * Looper.prepare();
         * Looper.loop();
         * */
        Toast.makeText(getActivity(),message,Toast.LENGTH_SHORT).show();
    }

}